In an electronic device having a USB interface such as a handheld terminal having a USB interface in the related art, one cable is shared as both a USB communication cable and a charging cable, that is, the cable can serve for both charging and USB communication. Thus the positive terminal VCHG of a charging interface of a mobile phone is short-circuited with a pin USB_VBUS directly or indirectly.
A USB interface circuit of a handheld terminal device includes two pins. One is a charging voltage pin VCHG on a power management chip, pin VCHG being configured to detect a state of plugging-in-or-pulling-out of a charger; it is determined that the charger is plugged in when the voltage at pin VCHG is greater than a certain threshold (e.g. 3.3V), and it is determined that the charger is pulled out when the voltage at pin VCHG is less than or equal to a certain threshold (e.g. 3.3V). The other pin is a USB-bus-power-supply positive terminal pin USB_VBUS of a USB interface chip; it is determined that plugging-in of a USB communication cable starts a USB state machine when the voltage at pin USB_VBUS is greater than a session value in a USB standard (e.g. 2.0V, which is a starting voltage of the USB state machine); and it is determined that a USB communication cable is pulled out when the voltage at pin USB_VBUS is no less than 0V and no more than the session value in the USB standard (e.g. 2.0V).
A condition for starting a charging state machine of a handheld terminal having a USB interface is as follows. It is determined, by detection, whether the positive terminal of the charging interface is greater than a certain threshold (e.g. 3.3V); if an input voltage is greater than the threshold, it is determined that the charger is plugged in, and charging management is started; and if it is not greater than the threshold, it is determined that the charger is pulled out, and charging has stopped. In addition, pin VCHG has a relatively wide range of operating voltages, which is normally between 10V and 20V (e.g. 18V), while pin USB_VBUS has a range of low operating voltages, the maximum operating voltage of USB_VBUS being 5.25V, normally.
In general, a condition for starting a USB state machine of a handheld terminal is as follows. It is determined whether the voltage at pin USB_VBUS (positive terminal of a USB bus power supply) is greater than the session value (e.g. 2.0V) in the USB standard; if an input voltage is greater than the session value , a USB enumeration process is started; and if it is no greater than the session value, the USB state machine is shut down. The maximum operating voltage of USB_VBUS is normally 5.25V which is relatively low. A problem thus brought forth is that the condition for starting the USB state machine is different from that for starting the charging state machine, which requires adoption of a circuit for distinguishing different signals so as to implement the start of USB communication. A usual practice in related art in a solution for starting USB communication with an interface shared by a charger and a USB communication cable is, as shown in FIG. 1, to lower the voltage at VCHG by a voltage-regulator diode before connecting VCHG to USB_VBUS. Such a method requires a relatively simple circuit, but fails to protect the device from the overshoot at the instant of plugging-in of the charger due to a low response speed of the voltage-regulator diode.
It is thus clear that sharing of an interface by a charger and a USB communication cable in the related art can easily cause damage to a mobile phone terminal device.